# -*- coding: utf-8 -*- 
# @project : 《Atcoder》
# @Author : created by bensonrachel on 2021/9/18
# @File : 7.Book Shop.py

def dp_01():
    dp = [0] * (x+ 1)
    for i in range(1,n+1):
        for j in range(x,rate1[i] - 1,-1):
            dp[j] = max(dp[j],dp[j-rate1[i]]+rate2[i])
    return (dp[x])
"""
01背包
"""
if __name__ == '__main__':
    n,x = map(int ,input().split())
    rate1 = [0]+[int(i) for i in input().split()]
    rate2 = [0]+[int(i) for i in input().split()]
    ans = dp_01()
    print(ans)